package cn.tsa.share.jdbc.shardingjdbc;

import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;

import java.util.Collection;

/**
 * 精确分片
 *
 * @author hongwei
 */
public class OrderPreciseShardingAlgorithm implements PreciseShardingAlgorithm<Long> {
    @Override
    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> preciseShardingValue) {
        Long idValue = preciseShardingValue.getValue();
        long delivery = idValue % 3 ;
        return preciseShardingValue.getLogicTableName() + delivery;
    }
}
